﻿#region License
/* Copyright (C) 2009 Tim Coulter
 * 
 * This file is part of ExtremeML.
 * 
 * ExtremeML is free software: you can redistribute
 * it and/or modify it under the terms of the GNU General Public
 * License, as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
 * the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
*/
#endregion

using DocumentFormat.OpenXml.Spreadsheet;

namespace ExtremeML.Spreadsheet
{
	// This is a partial class that adds custom functionality to its auto-generated partner.
	public sealed partial class AuthorWrapperCollection
	{
		#region Custom Properties


		#endregion
		#region Custom Methods

		/// <summary>
		/// Returns whether this collection contains wrapper for an author having the specified text value.
		/// </summary>
		/// <param name="value">The text value of the target author item.</param>
		/// <returns>A value that indicates whether a matching wrapper exists.</returns>
		internal bool Contains(
			string value)
		{
			return Find(value) != null;
		}

		/// <summary>
		/// Returns the wrapper for the author item having the specified text value.
		/// </summary>
		/// <param name="value">The text value of the target author item.</param>
		/// <returns>An <see cref="AuthorWrapper"/> that matches the specified text value. <c>null</c> if no match is found.</returns>
		internal AuthorWrapper Find(
			string value)
		{
			return Items.Find(item => item.Value == value);
		}

		/// <summary>
		/// Returns an <see cref="AuthorWrapper"/> that wraps a new <see cref="Author"/>.
		/// </summary>
		/// <param name="value">The string value of the author wrapper to create.</param>
		/// <returns>A new instance of <see cref="AuthorWrapper"/>.</returns>
		internal AuthorWrapper Add(
			string value)
		{
			var result = Add();
			result.Value = value;
			result.Activate();
			return result;
		}

		/// <summary>
		/// Returns the index of the passed item in the contained collection.
		/// </summary>
		/// <returns>The zero-based index of the passed item in the contained collection.</returns>
		internal int GetIndexOf(
			AuthorWrapper item)
		{
			return Items.IndexOf(item);
		}

		#endregion
		#region Overrides


		#endregion
		#region Implementation Methods


		#endregion
		#region Static Methods


		#endregion
	}
}
